﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using ig.app;
using Xamarin.Forms; 

namespace Hanselman.Portable.Views
{
    public partial class MenuPage : ContentPage
    {
        RootPage root;
        ObservableCollection<HomeMenuItem> menuItems;
        public MenuPage(RootPage root)
        {

            this.root = root;
            InitializeComponent();
            if (!App.IsWindows10)
            {
                BackgroundColor = Color.FromHex("#03A9F4");
                ListViewMenu.BackgroundColor = Color.FromHex("#F5F5F5");
            }
            BindingContext = new BaseViewModel
            {
                Title = "答题",
                Subtitle = "injoygo",
                Icon = "slideout.png"
            };

            ListViewMenu.ItemsSource = menuItems = new ObservableCollection<HomeMenuItem>()
                {
                    new HomeMenuItem { Title = "About", MenuType = MenuType.About, Icon ="about.png" },
                    new HomeMenuItem { Title = "Setting", MenuType = MenuType.Setting, Icon ="setting.png" },
                    new HomeMenuItem { Title = "Answer", MenuType = MenuType.Answer, Icon ="answer.png" },
                    new HomeMenuItem { Title = "Homework", MenuType = MenuType.Homework, Icon ="homework.png" },
                    //new HomeMenuItem { Title = "Blog", MenuType = MenuType.Blog, Icon = "blog.png" },
                    //new HomeMenuItem { Title = "Twitter", MenuType = MenuType.Twitter, Icon = "twitternav.png" },
                    //new HomeMenuItem { Title = "Hanselminues", MenuType = MenuType.Hanselminutes, Icon = "hm.png" },
                    //new HomeMenuItem { Title = "Ratchet", MenuType =MenuType.Ratchet, Icon = "ratchet.png" },
                    //new HomeMenuItem { Title = "Developers Life", MenuType = MenuType.DeveloperLife, Icon = "tdl.png"},

                };

    

            ListViewMenu.SelectedItem = menuItems[0];

            ListViewMenu.ItemSelected += async (sender, e) =>
                {
                    if (ListViewMenu.SelectedItem == null)
                        return;

                    await this.root.NavigateAsync(((HomeMenuItem)e.SelectedItem).MenuType);
                };
        }
    }
}

